
<?
$showtop = 0;
if($config['listtop_left'] || $config['listtop'] || $config['addbt'] || $config['search_items'] || $config['exportname'] || $config['importname'] || $config['more_top_bts'] || $config['listtop_right']) $showtop = 1;
if($showtop) { 
	echo '<div id="topBtDiv" style="border:1px solid #DDDDDD;background:#F5F5F5;padding:3px 10px;margin-bottom:10px;border-radius:5px;line-height:32px;'.($isphone?'box-shadow: 2px 2px 10px #bbbbbb;':'').'">';
}
$hasleft = false;
if($config['listtop_left'] || $config['addbt'] || $config['importname'] || $config['more_top_bts']) {
	$hasleft = true;
}

//if($hasleft) echo '<div class="top_float_div">';
if($config['listtop_left']) {
	$func = $config['listtop_left'];
	$func();
}

if($config['addbt']) {
	$style = $config['addbt_style'];
	if($config['importname'] || $config['more_top_bts']) $style .= "margin-right:5px;";
	else $style .= "margin-right:20px;";
	echo '<input class="button" type="button" value="'.$config['addbt'].'" style="cursor:pointer;'.$style.'" onclick="showInfo(0)" />';
}
if($config['importname']) {
	if($config['more_top_bts']) $margin = 5;
	else $margin = 20;
	$cover = 0;
	if($config['import_cover']) {
		$cover = 1;
	}
	echo '<input class="button" type="button" value="导入" style="cursor:pointer;margin-right:'.$margin.'px;" onclick="showImport('.$cover.')" />';
}
if($config['more_top_bts']) { 
	foreach($config['more_top_bts'] as $bn => $bt) {
		$bgcolor = $bt['bgcolor'];
		if(!$bgcolor) $bgcolor = $config_bgcolor;
		if($bn == count($config['more_top_bts']) - 1) $margin = 20;
		else $margin = 5;
		
		echo '<input class="button" type="button" value="'.$bt['title'].'" style="cursor:pointer;margin-right:'.$margin.'px;background:'.$bgcolor.';'.$bt['style'].'" onclick="'.$bt['onclick'].'" />';
	}
}
//if($hasleft) echo '</div>';

if($config['search_items']) {
	$has_text = false;
	foreach($config['search_items'] as $item) {
		$div_style = $item['div_style'];
		//echo '<div class="top_float_div" style="'.$div_style.'">';
		$value = p('search_'.$item['key']);
		if(!$value && isset($item['default'])) $value = $item['default'];
		if($item['title']) echo $item['title'].":";
?>

	<? if($item['type'] == 'text') { 
		$has_text = true;

		$text_id = "search-".$item['key'];

		$selectHtml = '';
		if($item['select']) {
			if(is_array($item['select'])) $selectHtml = ' onfocus="show_text_select(this, \''.$text_id.'\')" onclick="show_text_select(this, \''.$text_id.'\')" selectdata="'.rawurlencode(je($item['select'])).'" autocomplete="new-password" ';
			else $selectHtml = ' onfocus="show_text_select(this, \''.$text_id.'\', '.$item['select'].')" onclick="show_text_select(this, \''.$text_id.'\', '.$item['select'].')" autocomplete="new-password"  ';
		}

		?>
	<div style="position: relative;display: inline-block;"><input id="<?=$text_id?>" type="text" value="<?=$value?>" style="<? if($item['width']) echo 'width:'.($item['width']-18).'px;'; ?>padding-right: 18px;" onkeydown="if(event.keyCode == 13) search();"<?=$selectHtml?> /><img src="?act=getjscss&fn=images%2fclear.png" width="14" height="16" style="position:absolute;cursor:pointer;right: 5px;top: 50%;transform: translateY(-50%);" onclick="this.previousSibling.value='';search();" /></div>
	<? } else if($item['type'] == 'date') { 
			$has_text = true;
		?>
	<div style="position: relative;display: inline-block;"><input id="search-<?=$item['key']?>" type="text" value="<?=$value?>" style="width:95px;cursor:pointer;padding-right: 18px;" placeholder="点击选择" readonly /><img src="?act=getjscss&fn=images%2fclear.png" width="14" height="16" style="position:absolute;cursor:pointer;right: 5px;top: 50%;transform: translateY(-50%);" onclick="this.previousSibling.value='';search();" /></div>
	<? 
		$extraJs .= 'zaneDate({elem:\'#search-'.$item['key'].'\',begintime:\''.$value.'\'});';	
		} else if($item['type'] == 'textarea') { 
			$has_text = true;
			?>
	<textarea id="search-<?=$item['key']?>" style="<?=$item['style']?>;vertical-align:middle"><?=$value?></textarea>
	<? } else if($item['type'] == 'select') { 
		$has_text = true;
		$changeHtml = '';
		if($item['onchange']) {
			$changeHtml = htmlspecialchars($item['onchange']).(strstr($item['onchange'], '(')?"":"(this.value)").';';
		}
		?>
	<select id="search-<?=$item['key']?>"  onchange="<?=$changeHtml?><? if(!$item['no_auto_search']) { ?> search();<? } ?>"<? if($item['width']) echo ' style="width:'.$item['width'].'px"'; ?>>
		<? foreach($item['select'] as $key => $item2) { ?>
		<option value="<?=$key?>"<? if($value != '' && $value == $key) echo ' selected';?>><?=$item2?></option>
		<? } ?>
	</select>
	<? 
		} else if($item['type'] == 'tab') {?>

		<? 
		$n = 0;
		$nowN = 0;
		foreach($item['select'] as $key => $item2) {
			if($value != '' && $value == $key) {
				$nowN = $n;
			}
			$n++;
		}
		$n = 0;
		echo '<nobr>';
		foreach($item['select'] as $key => $item2) { 
			if($n == $nowN) {
				$tab_color = 'top_tab_color1';
			} else {
				$tab_color = 'top_tab_color2';
			}
			if($n == 0) {
				$tab_type = 'top_tab_type1';
			} else if($n == count($item['select']) - 1) {
				$tab_type = 'top_tab_type3';
			} else {
				$tab_type = 'top_tab_type2';
			}
			$n++;
			?><span class="top_tab <?=$tab_type?> <?=$tab_color?>" onclick="var a=this.parentNode.getElementsByTagName('span');for(var i=0;i<a.length;i++){if(a[i].className&&a[i].className.indexOf('top_tab')!=-1){a[i].className=a[i].className.replace('top_tab_color1','top_tab_color2');}}var cn=this.className;cn=cn.replace('top_tab_color2','top_tab_color1');this.className=cn;search('<?=$item['key']?>', '<?=$key?>');"><?=$item2?></span><? 
				
		} echo '</nobr>';?>

		<? } else if($item['type'] == 'hidden') {
			$text_id = "search-".$item['key'];
			?>
				<input id="<?=$text_id?>" type="hidden" value="<?=$value?>" />
			<?
		} 
	//echo '</div>';
} 

if($has_text) { ?>

<input id="searchBt" class="button" type="button" value="查询" style="cursor:pointer;" onclick="search()" />

<? }
} 

$hasright = false;
if($config['listtop'] || $config['exportname'] || $config['listtop_right']) {
	$hasright = true;
}

//if($hasright) echo '<div class="top_float_div">';
if($config['listtop']) {
	$func = $config['listtop'];
	$func();
}


if($config['exportname']) {
	echo '&nbsp;<input class="button" type="button" value="导出Excel" style="cursor:pointer" onclick="getListData(null, null, 1, this)" />';
}

if($config['listtop_right']) {
	$func = $config['listtop_right'];
	$func();
}


//if($hasright) echo '</div>';
//echo '<div style="clear:both;"></div>';
if($showtop) { 
	echo '</div>';
}
?>

<div id="list_content" style="100%"></div>

